package com.bw.module_home.adapter


import android.widget.ImageView
import android.widget.TextView
import com.baway.home.model.MsgResult
import com.bumptech.glide.Glide
import com.bw.module_message.R
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class MsgAdapter: BaseQuickAdapter<MsgResult, BaseViewHolder>(R.layout.item_notice_blue) {

    override fun convert(holder: BaseViewHolder, item: MsgResult) {
        val iv_icon = holder.getView<ImageView>(R.id.iv_icon)
        val tv_title = holder.getView<TextView>(R.id.tv_title)
        val tv_content = holder.getView<TextView>(R.id.tv_content)
        val tv_status = holder.getView<TextView>(R.id.tv_status)
        val tv_time = holder.getView<TextView>(R.id.tv_time)

        if (item.messageStatus.equals("已读")){
            holder.setBackgroundResource(R.id.tv_status,R.drawable.bg_msg_blue)
        }else if (item.messageStatus.equals("处理中")){
            holder.setBackgroundResource(R.id.tv_status,R.drawable.bg_msg_green)
        }else{
            holder.setBackgroundResource(R.id.tv_status,R.drawable.bg_msg_gray)
        }

        tv_title.setText(item.messageType)
        tv_content.setText(item.messageContent)
        tv_status.setText(item.messageStatus)
        tv_time.setText(item.sendTime)

        if (item.messageType.equals("系统通知")){
            Glide.with(context).load(R.drawable.icon_setting).into(iv_icon)
        }else if (item.messageType.equals("物业服务")){
            Glide.with(context).load(R.drawable.icon_sound).into(iv_icon)
        }else{
            Glide.with(context).load(R.drawable.icon_car).into(iv_icon)
        }
    }

}